/*
 * mod_coordinate_transform.h
 *
 *  Created on: 2025 Feb 18
 *      Author: SFLY
 */

#ifndef XTFOCLIB_MODULES_MOD_COORDINATE_TRANSFORM_H_
#define XTFOCLIB_MODULES_MOD_COORDINATE_TRANSFORM_H_


/** three-phase variables in stationary coordinate ****************************/
typedef struct {
    float Ia;
    float Ib;
    float Ic;
} stc_abc_t;

/** two-phase variables in stationary coordinate ******************************/
typedef struct {
    float Ialpha;
    float Ibeta;
} stc_ab_t;

/** two phase variables in rotation coordinate ********************************/
typedef struct {
    float Id;
    float Iq;
    float sin;
    float cos;
} stc_dq_t;

/**
 ******************************************************************************
 ** \brief: CLARKE transform: a-b-c => alpha-beta
 **         three-phase stationary variables to two-phase stationary variables
 **
 ** \param [in] stc_abc_t stcabc: three-phase variables
 ** \param [in] stc_ab_t* pstcab: pointer to two-phase variables
 **
 ** \retval     none
 ******************************************************************************/
void Transf_Clarke(stc_abc_t stcabc, stc_ab_t *pstcab);

/**
 *******************************************************************************
 ** \brief: INVERSE CLARKE transform: alpha-beta => a-b-c
 **         two-phase stationary variables to three-phase stationary variables
 **
 ** \param [in] stc_ab_t stcab: two-phase variables
 ** \param [in] stc_uvw_t* pstcabc: pointer to three-phase variables
 **
 ** \retval     none
 ******************************************************************************/
void Transf_InvClarke(stc_ab_t stcab, stc_abc_t *pstcabc);

/**
 *******************************************************************************
 ** \brief: PARK transform: alpha-beta => d-q
 **         two-phase stationary variables to two-phase rotation variables
 **
 ** \param [in] stc_ab_t stcab: two-phase stationary variables
 ** \param [in] stc_dq_t* pstcdq: pointer to two-phase rotation variables
 **
 ** \retval     none
 ******************************************************************************/
void Transf_Park(stc_ab_t stcab, stc_dq_t *pstcdq);

/**
 *******************************************************************************
 ** \brief: INVERSE PARK transform: d-q => alpha-beta
 **         two-phase rotation variables to two-phase stationary variables
 **
 ** \param [in] stc_dq_t stcdq: two-phase rotation variables
 ** \param [in] stc_ab_t* pstcab: pointer to two-phase stationary variables
 **
 ** \retval     none
 ******************************************************************************/
void Transf_InvPark(stc_dq_t stcdq, stc_ab_t *pstcab);

#endif /* XTFOCLIB_MODULES_MOD_COORDINATE_TRANSFORM_H_ */
